package com.samsung.calendar;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Paint.FontMetrics;
import android.graphics.Paint.Style;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AnimationUtils;

import com.samsung.R;

public class MonthlyCalendarView extends View {
	
	private final MonthlyCalendar monthlycalendar;
	public MonthlyCalendarView(Context context) {
		super(context);
		this.monthlycalendar = (MonthlyCalendar) context;
//		setFocusable(true);
//		setFocusableInTouchMode(true);
	}
	
	private float width;
	private float height;
	private int selX;
	private int selY;
	private final Rect selRect = new Rect ();
	
	@Override
	protected void onSizeChanged(int w, int h, int oldw, int oldh) {
	width = w / 9f;
	height = h / 9f;
	getRect(selX, selY, selRect);
	super.onSizeChanged(w, h, oldw, oldh);
	}

	private void getRect(int x, int y, Rect rect) {
		rect.set((int) (x * width), (int) (y * height), (int) (x *width + width), (int) (y*height+height));
	}

	protected void onDraw(Canvas canvas) {
		
		Paint background = new Paint();
//		background.setColor(getResources().getColor(R.color.background));
		canvas.drawRect(0,0,getWidth(), getHeight(), background);
		
		Paint black = new Paint();
		black.setColor(getResources().getColor(R.color.black));
		
		for (int i = 0; i < 9; i++) {
			canvas.drawLine(0, i * height, getWidth(), i * height, black);
			canvas.drawLine(0, i * height + 1, getWidth(), i * height + 1, black);
			canvas.drawLine(i * width, 0, i * width, getHeight(), black);
			canvas.drawLine(i * width + 1, 0, i *width + 1, getHeight(), black);
			}
		
		for (int i = 0; i < 9; i++) {
			canvas.drawLine(0, i * height, getWidth(), i * height, black);
			canvas.drawLine(0, i * height + 1, getWidth(), i * height + 1, black);
			canvas.drawLine(i * width, 0, i * width, getHeight(), black);
			canvas.drawLine(i * width + 1, 0, i *width + 1, getHeight(), black);
			}
	}
}